package com.dycloud.project.controller.user;

import com.dycloud.project.constant.Constants;
import com.dycloud.project.domain.Course;
import com.dycloud.project.enums.ReviewStatusEnum;
import com.dycloud.project.service.ICourseService;
import com.dycloud.project.web.controller.BaseController;
import com.dycloud.project.web.domain.AjaxResult;
import com.dycloud.project.web.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * @author : renhang
 * @description CourseController
 * @date : 2025-07-02 21:52
 **/
@RestController
@RequestMapping("/user/course")
public class UserCourseController extends BaseController {
    @Autowired
    private ICourseService courseService;

    /**
     * 查询课程信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(Course course) {
        startPage();
        course.setStatus(ReviewStatusEnum.PUBLISHED.getCode());
        course.setIsActive(Constants.ONE);
        return courseService.selectCourseList(course);
    }


    /**
     * 获取课程信息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(courseService.selectCourseById(id));
    }


}